package myself.a011HowAreYou;

/**
 * @author 叶之越
 * Description 居民区和荒宅点亮问题
 * Date 2021/1/30
 * Time 22:05
 * Mail 739153436@qq.com
 */
public class Light {

    public static int minLight2(String road) {
        if (road == null || road == "") {
            return 0;
        }
        char[] arr = road.toCharArray();
        int count = 0;
        for (int i = 0; i < arr.length; i++) {
            char cur = arr[i];
            if (cur == 'X') {
                continue;
            } else {
                if (i + 1 < arr.length && arr[i + 1] == '.') {
                    i += 2;
                } else {
                    i++;
                }
                count++;
            }
        }
        return count;
    }
}
